package com.xhh.preenroll.controller.v1;


import com.xhh.model.common.dtos.ResponseResult;
import com.xhh.model.preenroll.dtos.CancelStatusDto;
import com.xhh.model.preenroll.dtos.PreenrollPageDto;
import com.xhh.model.preenroll.dtos.SendNoticeDto;
import com.xhh.model.preenroll.dtos.UpdateStatusDto;
import com.xhh.preenroll.service.IPreenrollService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xhh
 * @since 2024-08-07
 */
@Api(tags = "待录取管理接口")
@RestController
@RequestMapping("/preenroll")
@RequiredArgsConstructor
public class PreenrollController {

    private final IPreenrollService preenrollService;

    @ApiOperation("发送待录取通知")
    @PostMapping("sendNotice")
    public ResponseResult notice(@RequestBody SendNoticeDto dto){
        return preenrollService.notice(dto);
    }

    @ApiOperation("查看待录取通知")
    @GetMapping("getNotice")
    public ResponseResult getNotice(){
        return preenrollService.getNotice();
    }

    @ApiOperation("处理待录取通知")
    @PutMapping("markNoticeStatusAcceptOrRefuse")
    public ResponseResult markNoticeStatusAcceptOrRefuse(@RequestBody UpdateStatusDto dto){
        return preenrollService.markNoticeStatusAcceptOrRefuseByStudent(dto);
    }

    @ApiOperation("分页条件查询待录取通知")
    @GetMapping("getNoticeByPageAndCondition")
    public ResponseResult getNoticeByPageAndCondition(PreenrollPageDto dto){
        return preenrollService.getNoticeByPageAndCondition(dto);
    }

    @ApiOperation("招生单位取消考生的待录取资格")
    @PostMapping("cancelStuQualification/{pId}")
    public ResponseResult cancelStuQualification(@PathVariable("pId") Long pId){
        return preenrollService.cancelStuQualification(pId);
    }

    @ApiOperation("考生是否同意招生单位取消待录取资格")
    @PutMapping("isAcceptCancel")
    public ResponseResult isAcceptCancel(@RequestBody CancelStatusDto dto){
        return preenrollService.isAcceptCancel(dto);
    }

    @ApiOperation("考生申请解除已同意的待录取")
    @PostMapping("undoAccept/{pId}")
    public ResponseResult undoAccept(@PathVariable("pId") Long pId){
        return preenrollService.undoAccept(pId);
    }

    @ApiOperation("招生单位是否同意考生解除待录取的申请")
    @PutMapping("isAcceptRequest")
    public ResponseResult isAcceptRequest(@RequestBody UpdateStatusDto dto){
        return preenrollService.isAcceptRequest(dto);
    }

}
